package com.xiaoxi.exam.dao;

import com.xiaoxi.exam.model.BoughtRecord;
import com.xiaoxi.exam.model.BoughtRecordExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface BoughtRecordMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    long countByExample(BoughtRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    int deleteByExample(BoughtRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    @Update({
        "update s_business.t_bought_record",
        "set deleted_at = now()",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    @Select({
        "insert into s_business.t_bought_record (buyer_id, deal_at, ",
        "order_id, exam_id, created_at, ",
        "updated_at, deleted_at, ",
        "count, sort_no, book_status)",
        "values (#{buyerId,jdbcType=BIGINT}, #{dealAt,jdbcType=TIMESTAMP}, ",
        "#{orderId,jdbcType=BIGINT}, #{examId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, ",
        "#{updatedAt,jdbcType=TIMESTAMP}, #{deletedAt,jdbcType=TIMESTAMP}, ",
        "#{count,jdbcType=BIGINT}, #{sortNo,jdbcType=SMALLINT}, #{bookStatus,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler})", 
        " returning id"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    long insertReturningId(BoughtRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    @Insert({
        "insert into s_business.t_bought_record (buyer_id, deal_at, ",
        "order_id, exam_id, created_at, ",
        "updated_at, deleted_at, ",
        "count, sort_no, book_status)",
        "values (#{buyerId,jdbcType=BIGINT}, #{dealAt,jdbcType=TIMESTAMP}, ",
        "#{orderId,jdbcType=BIGINT}, #{examId,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, ",
        "#{updatedAt,jdbcType=TIMESTAMP}, #{deletedAt,jdbcType=TIMESTAMP}, ",
        "#{count,jdbcType=BIGINT}, #{sortNo,jdbcType=SMALLINT}, #{bookStatus,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(BoughtRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    long insertSelectiveReturningId(BoughtRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    int insertSelective(BoughtRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    List<BoughtRecord> selectByExample(BoughtRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    @Select({
        "select",
        "id, buyer_id, deal_at, order_id, exam_id, created_at, updated_at, deleted_at, ",
        "count, sort_no, book_status",
        "from s_business.t_bought_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("com.xiaoxi.exam.dao.BoughtRecordMapper.BaseResultMap")
    BoughtRecord selectByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    int updateByExampleSelective(@Param("record") BoughtRecord record, @Param("example") BoughtRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    int updateByExample(@Param("record") BoughtRecord record, @Param("example") BoughtRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    int updateByPrimaryKeySelective(BoughtRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table s_business.t_bought_record
     *
     * @mbg.generated Thu Oct 11 13:53:50 CST 2018
     */
    @Update({
        "update s_business.t_bought_record",
        "set buyer_id = #{buyerId,jdbcType=BIGINT},",
          "deal_at = #{dealAt,jdbcType=TIMESTAMP},",
          "order_id = #{orderId,jdbcType=BIGINT},",
          "exam_id = #{examId,jdbcType=BIGINT},",
          "created_at = #{createdAt,jdbcType=TIMESTAMP},",
          "updated_at = #{updatedAt,jdbcType=TIMESTAMP},",
          "deleted_at = #{deletedAt,jdbcType=TIMESTAMP},",
          "count = #{count,jdbcType=BIGINT},",
          "sort_no = #{sortNo,jdbcType=SMALLINT},",
          "book_status = #{bookStatus,jdbcType=SMALLINT,typeHandler=com.xiaoxi.exam.mybatis.typehandlers.EnumCodeHandler}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(BoughtRecord record);
}